import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/user/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: {token}
  })
}

export function logout() {
  return request({
    url: '/user/logout',
    method: 'post'
  })
}

/**
 * 获取用户列表
 * @param {*} query
 */
export function listUser(query) {
  return request({
    url: '/user/list',
    method: 'get',
    params: query
  })
}

export function assignRole(query) {
  return request({
    url: '/user/assginRole',
    method: 'post',
    data: query
  })
}




/**
 * 删除用户
 * @param {*} data
 */
export function deleteUser(data) {
  return request({
    url: '/user/del/' + data,
    method: 'delete'
  })
}

/**
 * 新增用户接口
 * @param {*} data
 */
export function addUser(data) {
  return request({
    url: '/user/create',
    method: 'post',
    data
  })
}

/**
 * 获取用户详细信息
 * @param {*} id 用户id
 */
export function detailUser(id) {
  return request({
    url: '/user/detail',
    method: 'get',
    params: {id}
  })
}

/**
 * 更新用户信息
 * @param {*} data
 */
export function editUser(data) {
  return request({
    url: 'user/update',
    method: 'post',
    data
  })
}
